package com.example.arithmeticleetcode.leetcode.dec;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-12-16 09:42
 **/
public class Demo13 {

    public List<Integer> luckyNumbers(int[][] matrix) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < matrix.length; i++) {
            int minValue = matrix[i][0];
            int mindIndex = 0;
            for (int j = 1; j < matrix[i].length; j++) {
                if (minValue > matrix[i][j]) {
                    minValue = matrix[i][j];
                    mindIndex = j;
                }
            }
            boolean flag = true;
            for (int k = 0; k < matrix.length; k++) {
                if (minValue < matrix[k][mindIndex]) {
                    flag = false;
                    break;
                }
            }
            if (flag) list.add(minValue);
        }
        return list;
    }
}
